using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace EditWebSite.Controls
{
    internal partial class CustomTabPage : UserControl
    {
        public event EventHandler EseguiQuery;

        public SyntaxText TxtSql
        {
            get {return txtSql; }
            set { txtSql = value; }
        }
        public DataGridView Dgv
        {
            get { return dgv; }
            set { dgv = value; }
        }

        public CustomTabPage()
        {
            InitializeComponent();
            dgv.RowsAdded += new DataGridViewRowsAddedEventHandler(dgv_RowsAdded);
        }

        void dgv_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                dgv.Rows[i].HeaderCell.Value = i + 1;
            }
        }

        private void OnEseguiQuery()
        {
            if (EseguiQuery != null)
            {
                EseguiQuery(this, new EventArgs());
            }
        }

        private void txtSql_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                OnEseguiQuery();
            }
        }
    }
}
